package com.ruoyi.backstage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zzw.domain.PeopleEvent;
import com.ruoyi.zzw.service.TPeopleEventService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 突发事件人员关联表Controller
 * 
 * @author ruoyi
 * @date 2023-12-06
 */
@RestController
@RequestMapping("/backstage/event")
public class BackPeopleEventController extends BaseController
{
    @Autowired
    private TPeopleEventService tPeopleEventService;

    /**
     * 查询突发事件人员关联表列表
     */
    @PreAuthorize("@ss.hasPermi('system:event:list')")
    @GetMapping("/list")
    public TableDataInfo list(PeopleEvent peopleEvent)
    {
        startPage();
        List<PeopleEvent> list = tPeopleEventService.selectTPeopleEventList(peopleEvent);
        return getDataTable(list);
    }

    /**
     * 导出突发事件人员关联表列表
     */
    @PreAuthorize("@ss.hasPermi('system:event:export')")
    @Log(title = "突发事件人员关联表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PeopleEvent peopleEvent)
    {
        List<PeopleEvent> list = tPeopleEventService.selectTPeopleEventList(peopleEvent);
        ExcelUtil<PeopleEvent> util = new ExcelUtil<PeopleEvent>(PeopleEvent.class);
        util.exportExcel(response, list, "突发事件人员关联表数据");
    }

    /**
     * 获取突发事件人员关联表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:event:query')")
    @GetMapping(value = "/{cPeopleDuty}")
    public AjaxResult getInfo(@PathVariable("cPeopleDuty") Long cPeopleDuty)
    {
        return success(tPeopleEventService.selectTPeopleEventByCPeopleDuty(cPeopleDuty));
    }

    /**
     * 新增突发事件人员关联表
     */
    @PreAuthorize("@ss.hasPermi('system:event:add')")
    @Log(title = "突发事件人员关联表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PeopleEvent peopleEvent)
    {
        return toAjax(tPeopleEventService.insertTPeopleEvent(peopleEvent));
    }

    /**
     * 修改突发事件人员关联表
     */
    @PreAuthorize("@ss.hasPermi('system:event:edit')")
    @Log(title = "突发事件人员关联表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PeopleEvent peopleEvent)
    {
        return toAjax(tPeopleEventService.updateTPeopleEvent(peopleEvent));
    }

    /**
     * 删除突发事件人员关联表
     */
    @PreAuthorize("@ss.hasPermi('system:event:remove')")
    @Log(title = "突发事件人员关联表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cPeopleDutys}")
    public AjaxResult remove(@PathVariable Long[] cPeopleDutys)
    {
        return toAjax(tPeopleEventService.deleteTPeopleEventByCPeopleDutys(cPeopleDutys));
    }
}
